# cuDNN验证
import torch
from torch.nn import Conv2d

# 检查CUDA是否可用
print("CUDA available:", torch.cuda.is_available())
# 检查cuDNN是否可用
print("cuDNN available:", torch.backends.cudnn.is_available())
# 创建一个卷积层并移动到GPU
conv = Conv2d(3, 16, kernel_size=3).cuda()
# 创建一个输入张量并移动到GPU
input_tensor = torch.randn(1, 3, 224, 224).cuda()
# 执行卷积操作
output = conv(input_tensor)
# 打印输出张量的形状
print("Output shape:", output.shape)